package com.sport.utils;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 分页数据返回
 * @Author 阿杰
 * @create 2021-03-31 14:56
 */
@Data
@ApiModel(value = "分页响应数据")
public class PageResult extends Result implements Serializable {

    /**
     * 分页数据
     */
    @ApiModelProperty(value = "分页的数据")
    private List<?> rows;

    private boolean flag;
    private String message;
    /**
     * 数据总条数
     */
    @ApiModelProperty(value = "数据总条数")
    private long total;

    public PageResult(long total,List<?> list) {

        this.setFlag(true);
        this.setMessage("分页查询成功");
        this.rows = list;
        this.total = total;
    }

    /**
     * 分页总条数
     * @param total
     * @param list
     * @return
     */
    public static Result pageResult(long total,List<?> list){
        return new PageResult(total,list);
    }
}
